package com.example.controller;

import com.example.common.Result;
import com.example.entity.Foodtable;
import com.example.entity.PageBean;
import com.example.service.FoodtableService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/Foodtable")
public class FoodtableController {
    @Autowired
    private FoodtableService foodtableService;
    @GetMapping("/page")
    public Result page(@RequestParam(defaultValue = "1") Integer page,
                       @RequestParam(defaultValue = "30") Integer pageSize, String tableCondition) {
        PageBean pageBean = foodtableService.page(page, pageSize, tableCondition);
        return Result.success(pageBean);
    }
    @PostMapping("/add")
    public Result add(@RequestBody Foodtable foodtable) {
        foodtableService.add(foodtable);
        return Result.success();
    }
    @DeleteMapping("/delete")
    public Result delete(@RequestParam("table_id") String table_id) {
        foodtableService.delete(table_id);
        return Result.success();
    }
    @PutMapping("/updata")
    public Result updata(@RequestBody Foodtable foodtable){
        foodtableService.updata(foodtable);
        return Result.success();
    }
}
